class StudentManagementSystem:
    def __init__(self):
        """初始化学生列表"""
        self.students = []

    def add_student(self, student_id, name, age, major):
        """添加学生信息"""
        # 检查学号是否已存在
        for student in self.students:
            if student['student_id'] == student_id:
                print(f"错误：学号 {student_id} 已存在！")
                return False

        # 创建新学生字典
        new_student = {
            'student_id': student_id,
            'name': name,
            'age': age,
            'major': major
        }

        self.students.append(new_student)
        print(f"成功添加学生：{name}（学号：{student_id}）")
        return True

    def delete_student(self, student_id):
        """删除学生信息"""
        for i, student in enumerate(self.students):
            if student['student_id'] == student_id:
                deleted_name = self.students.pop(i)['name']
                print(f"已删除学生：{deleted_name}（学号：{student_id}）")
                return True

        print(f"错误：未找到学号为 {student_id} 的学生")
        return False

    def find_student(self, student_id):
        """查找学生信息"""
        for student in self.students:
            if student['student_id'] == student_id:
                print("\n找到学生信息：")
                print(f"学号：{student['student_id']}")
                print(f"姓名：{student['name']}")
                print(f"年龄：{student['age']}")
                print(f"专业：{student['major']}")
                return student

        print(f"未找到学号为 {student_id} 的学生")
        return None

    def show_all_students(self):
        """显示所有学生信息"""
        if not self.students:
            print("当前没有学生信息")
            return

        print("\n所有学生信息：")
        print("-" * 40)
        print(f"{'学号':<10}{'姓名':<10}{'年龄':<5}{'专业':<15}")
        print("-" * 40)

        for student in self.students:
            print(f"{student['student_id']:<10}"
                  f"{student['name']:<10}"
                  f"{student['age']:<5}"
                  f"{student['major']:<15}")

        print("-" * 40)
        print(f"共 {len(self.students)} 名学生")


# 使用示例
if __name__ == "__main__":
    sms = StudentManagementSystem()

    # 添加学生
    sms.add_student("1001", "张三", 20, "计算机科学")
    sms.add_student("1002", "李四", 21, "软件工程")
    sms.add_student("1003", "王五", 22, "数据科学")

    # 尝试添加重复学号
    sms.add_student("1001", "赵六", 19, "网络安全")

    # 显示所有学生
    sms.show_all_students()

    # 查找学生
    sms.find_student("1002")

    # 删除学生
    sms.delete_student("1003")

    # 再次显示所有学生
    sms.show_all_students()